#ifndef ESP01S_MQTT_WEB_RETRYMANAGER_H
#define ESP01S_MQTT_WEB_RETRYMANAGER_H

#include <functional>
#include <Arduino.h>

// 假设 debugLog 函数在别处定义，这里先声明
void debugLog(const char* format, ...);

class RetryManager {
public:
    // 修改参数类型为 std::function<bool()>
    bool retryOperationNonBlocking(std::function<bool()> operation, const char* errorMsg, int retryCount = 3, unsigned long interval = 1000);

private:
    unsigned long lastRetryTime = 0;
    int currentRetry = 0;
};

extern RetryManager retryManager;

#endif